﻿using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using K9Nano.Events.Entity;
using K9Nano.Runtime;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;

namespace K9Nano.EFCore
{
    public interface IDbContextHelper
    {
        DbContext DbContext { get; set; }
        ISessionContext SessionContext { get; }
        IGlobalFilterProvider GlobalFilterProvider { get; }
        IEntityChangeReport EntityChangeReport { get; }
        ISystemClock SystemClock { get; }
        IEntityCacheFilter EntityCacheFilter { get; }
        IEntityEventFilter EntityEventFilter { get; }
        bool MultiTenancy { get; }
        bool FiltersDisabled { get; set; }
        bool SuppressAutoSetTenantId { get; set; }
        bool EventsDisabled { get; set; }
        void OnModelCreating(ModelBuilder modelBuilder);
        string GetConventionalTableName(string tableName);
        void SetValueIfNull(EntityEntry entry, string key, object value);
        int SaveChanges(bool acceptAllChangesOnSuccess, Func<bool, int> baseSaveChanges);
        Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellation, Func<bool, CancellationToken, Task<int>> baseSaveChanges);
        IQueryable<TEntity> Queryable<TEntity>() where TEntity : class;
    }
}